package com.macro.mall.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author ：小海
 * @dete ：2021-04-03 19:06:43
 * @Describe : Swagger2配置
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket webApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //为当前包下的controller生成api文档
                .apis(RequestHandlerSelectors.basePackage("com.macro.mall.controller")) .paths(PathSelectors.any())
                .build();

    }


    private ApiInfo apiInfo() {
        //设置文档信息
        return new ApiInfoBuilder() .title("数据备份中心API文档")
                .description("本文档描述了数据备份中心接口定义")
                .contact(new Contact("小海", "http:localhost:8110/doc.html", "xxxx@xxxx.com"))
                .version("1.0") .build();
    }
}
